package com.corner.utils;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.corner.R;


public class DialogUtil {
    public static Dialog showProgressDialog(Context context) {
        Dialog dialog = new Dialog(context, R.style.DialogStyle);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        dialog.setCanceledOnTouchOutside(false);
        View view = View.inflate(context, R.layout.dialog_progress, null);
        dialog.setContentView(view);
        dialog.show();
        return dialog;
    }

    public static void hideDialog(Dialog dialog) {
        dialog.hide();
    }

    /**
     * 显示相应Layout的对话框
     *
     * @param resId
     * @param context
     * @return
     */
    public static Dialog showDiaLog(int resId, Context context) {
        Dialog dialog = new Dialog(context, R.style.DialogStyle);
        View view = View.inflate(context, resId, null);
        dialog.setContentView(view);
        dialog.getWindow().setGravity(Gravity.CENTER);
        dialog.show();
        return dialog;
    }
}
